package com.ruoyi.jhc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jhc.domain.JhcFq;
import com.ruoyi.jhc.service.IJhcFqService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 附企进耗存录入Controller
 * 
 * @author ruoyi
 * @date 2023-04-07
 */
@RestController
@RequestMapping("/jhc/fq")
public class JhcFqController extends BaseController
{
    @Autowired
    private IJhcFqService jhcFqService;

    /**
     * 查询附企进耗存录入列表
     */
    @PreAuthorize("@ss.hasPermi('jhc:fq:list')")
    @GetMapping("/list")
    public TableDataInfo list(JhcFq jhcFq)
    {
        startPage();
        List<JhcFq> list = jhcFqService.selectJhcFqList(jhcFq);
        return getDataTable(list);
    }

    /**
     * 导出附企进耗存录入列表
     */
    @PreAuthorize("@ss.hasPermi('jhc:fq:export')")
    @Log(title = "附企进耗存录入", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JhcFq jhcFq)
    {
        List<JhcFq> list = jhcFqService.selectJhcFqList(jhcFq);
        ExcelUtil<JhcFq> util = new ExcelUtil<JhcFq>(JhcFq.class);
        util.exportExcel(response, list, "附企进耗存录入数据");
    }

    /**
     * 获取附企进耗存录入详细信息
     */
    @PreAuthorize("@ss.hasPermi('jhc:fq:query')")
    @GetMapping(value = "/{cDate}")
    public AjaxResult getInfo(@PathVariable("cDate") String cDate)
    {
        return AjaxResult.success(jhcFqService.selectJhcFqByCDate(cDate));
    }

    /**
     * 新增附企进耗存录入
     */
    @PreAuthorize("@ss.hasPermi('jhc:fq:add')")
    @Log(title = "附企进耗存录入", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JhcFq jhcFq)
    {
        return toAjax(jhcFqService.insertJhcFq(jhcFq));
    }

    /**
     * 修改附企进耗存录入
     */
    @PreAuthorize("@ss.hasPermi('jhc:fq:edit')")
    @Log(title = "附企进耗存录入", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JhcFq jhcFq)
    {
        return toAjax(jhcFqService.updateJhcFq(jhcFq));
    }

    /**
     * 删除附企进耗存录入
     */
    @PreAuthorize("@ss.hasPermi('jhc:fq:remove')")
    @Log(title = "附企进耗存录入", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cDates}")
    public AjaxResult remove(@PathVariable String[] cDates)
    {
        return toAjax(jhcFqService.deleteJhcFqByCDates(cDates));
    }
}
